<!DOCTYPE html>












  




<html class="theme-next gemini use-motion" lang="zh-CN">
<head>
  <!-- hexo-inject:begin --><!-- hexo-inject:end --><meta charset="UTF-8"/>
<meta name="google-site-verification" content="o9IkI77-fxkhBZW-n0ww9JALMCqdDbeTgdcXO_Bw4Zc" />
<meta name="baidu-site-verification" content="3frqY9KiVO" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2"/>
<meta name="theme-color" content="#222">



  
  
  <link rel="stylesheet" href="/lib/needsharebutton/needsharebutton.css">










<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />



















  
  
  
  

  
    
    
  

  
    
      
    

    
  

  

  
    
      
    

    
  

  
    
      
    

    
  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Monda:300,300italic,400,400italic,700,700italic|Roboto Slab:300,300italic,400,400italic,700,700italic|Lobster Two:300,300italic,400,400italic,700,700italic|PT Mono:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=6.4.1" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/logo.png?v=6.4.1">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/logo.png?v=6.4.1">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/logo.png?v=6.4.1">


  <link rel="mask-icon" href="/images/logo.svg?v=6.4.1" color="#222">









<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '6.4.1',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="摘要：数学在计算机科学、机器学习、深度学习、自然语言处理等多个领域占据比较重要的位置。比如：特征值和特征向量在PCA降维中会使用；均值在回归算法中估计公式参数中使用；期望和均值在回归方程应用；余弦定理求相似度中运用；拉格朗日定理在支持向量机中使用；求导在解决梯度下降中使用；矩阵和向量在数据格式转换和预处理中运用等等。还有在算法建模、参数设置、验证策略、识别欠拟合和过拟合等方面依然应用广泛。本系列">
<meta name="keywords" content="数学,矩阵">
<meta property="og:type" content="article">
<meta property="og:title" content="编程数学之矩阵">
<meta property="og:url" content="https://bainingchao.github.io/2018/10/10/编程数学之矩阵/index.html">
<meta property="og:site_name" content="白宁超的官网">
<meta property="og:description" content="摘要：数学在计算机科学、机器学习、深度学习、自然语言处理等多个领域占据比较重要的位置。比如：特征值和特征向量在PCA降维中会使用；均值在回归算法中估计公式参数中使用；期望和均值在回归方程应用；余弦定理求相似度中运用；拉格朗日定理在支持向量机中使用；求导在解决梯度下降中使用；矩阵和向量在数据格式转换和预处理中运用等等。还有在算法建模、参数设置、验证策略、识别欠拟合和过拟合等方面依然应用广泛。本系列">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?{\displaystyle {\begin{bmatrix}1&9&-13\\20&5&-6\end{bmatrix}}} ">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?{\displaystyle \mathbf {A} ={\begin{bmatrix}9&13&5\\1&11&7\\3&9&2\\6&0&7\end{bmatrix}}}  ">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?\begin{bmatrix}
1 &3  &1 \\ 
1 &0  &0 
\end{bmatrix}+\begin{bmatrix}
0 &0  &5 \\ 
7 &5  &0 
\end{bmatrix}=\begin{bmatrix}
1+0 &3+0  &1+5 \\ 
1+7 &0+5  &0 +0
\end{bmatrix}=\begin{bmatrix}
1 &3  &6 \\ 
8 &5  &0 
\end{bmatrix}">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?\begin{bmatrix}
1 &3  &1 \\ 
1 &0  &0 
\end{bmatrix}-\begin{bmatrix}
0 &0  &5 \\ 
7 &5  &0 
\end{bmatrix}=\begin{bmatrix}
1-0 &3-0  &1-5 \\ 
1-7 &0-5  &0 -0
\end{bmatrix}=\begin{bmatrix}
1 &3  &-4 \\ 
-6 &-5  &0 
\end{bmatrix}">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?2*\begin{bmatrix}
1 &3  &1 \\ 
1 &0  &0 
\end{bmatrix}=\begin{bmatrix}
2*1 &2*3  &2*1 \\ 
2*1 &2*0  &2*0 
\end{bmatrix}=\begin{bmatrix}
2 &6  &2 \\ 
2 &0  &0 
\end{bmatrix}">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?\begin{bmatrix}
1 &2  &3 \\ 
4 &5  &6 
\end{bmatrix}^T=\begin{bmatrix}
1 &4 \\ 
2 &5 \\ 
3 &6 
\end{bmatrix}">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?A=\begin{bmatrix}
3+i &5  \\ 
2-2i  &i 
\end{bmatrix}">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?\overline A=\begin{bmatrix}
3-i &5  \\ 
2+2i  &-i 
\end{bmatrix}">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?{\displaystyle {\begin{cases}a_{1,1}x_{1}+a_{1,2}x_{2}+\cdots +a_{1,n}x_{n}=b_{1}\\a_{2,1}x_{1}+a_{2,2}x_{2}+\cdots +a_{2,n}x_{n}=b_{2}\\\vdots \quad \quad \quad \vdots \\a_{m,1}x_{1}+a_{m,2}x_{2}+\cdots +a_{m,n}x_{n}=b_{m}\end{cases}}} ">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?{\displaystyle \mathbf {A} ={\begin{bmatrix}a_{1,1}&a_{1,2}&\cdots &a_{1,n}\\a_{2,1}&a_{2,2}&\cdots &a_{2,n}\\\vdots &\vdots &\ddots &\vdots \\a_{m,1}&a_{m,2}&\cdots &a_{m,n}\end{bmatrix}},\quad \mathbf {x} ={\begin{bmatrix}x_{1}\\x_{2}\\\vdots \\x_{n}\end{bmatrix}},\quad \mathbf {b} ={\begin{bmatrix}b_{1}\\b_{2}\\\vdots \\b_{m}\end{bmatrix}}} ">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?A=\begin{bmatrix}
a_{1,1}  &a_{1,2}  \\ 
a_{2,1}  &a_{2,2} 
\end{bmatrix}">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?A=\begin{bmatrix}
a_{1,1}  &a_{1,2}  \\ 
a_{2,1}  &a_{2,2} 
\end{bmatrix}">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?\begin{bmatrix}
           d_{11} & 0 & 0 \\
           0 & d_{22} & 0 \\
           0 & 0 & d_{33} \\
        \end{bmatrix}">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?\begin{bmatrix}
           u_{11} & u_{12} & u_{13} \\
           0 & u_{22} & u_{23} \\
           0 & 0 & u_{33} \\
        \end{bmatrix}">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?\begin{bmatrix}
           l_{11} & 0 & 0 \\
           l_{21} & l_{22} & 0 \\
           l_{31} & l_{32} & l_{33} \\
        \end{bmatrix}">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?A=(a_{11})">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?|A|=a_{11}">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?A=\begin{pmatrix}
a_{11} & a_{12} \\
a_{21} & a_{22} 
\end{pmatrix}">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?|A|=a_{11}a_{22}-a_{12}a_{21}">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?A=\begin{pmatrix}
a_{11} & a_{12} & a_{13} \\
a_{21} & a_{22} & a_{23} \\
a_{31} & a_{32} & a_{33}
\end{pmatrix}">
<meta property="og:image" content="https://i.imgur.com/a9DmDiZ.png">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?|A|=a_{11}a_{22}a_{33}+a_{12}a_{23}a_{31}+a_{13}a_{21}a_{32}-a_{11}a_{23}a_{32}-a_{12}a_{21}a_{33}-a_{13}a_{22}a_{31}">
<meta property="og:image" content="https://i.imgur.com/5dhejWE.png">
<meta property="og:image" content="https://i.imgur.com/gJYS8oI.png">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?|A|=\sum_{i=1}^{n}a_{ij}(-1)^{i+j}M_{ij} , \forall \leqslant j \leqslant n">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?|A|=\sum_{j=1}^{n}a_{ij}(-1)^{i+j}M_{ij} , \forall \leqslant i \leqslant n">
<meta property="og:image" content="http://latex.codecogs.com/gif.latex?|A|=a_{11}(a_{22}a_{33}-a_{23}a_{32})+a_{12}(a_{21}a_{33}-a_{23}a_{31})+a_{13}(a_{21}a_{32}-a_{23}a_{31})">
<meta property="og:image" content="http://pub.idqqimg.com/wpa/images/group.png">
<meta property="og:image" content="https://i.imgur.com/cvixeiT.png">
<meta property="og:updated_time" content="2018-10-19T07:41:49.001Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="编程数学之矩阵">
<meta name="twitter:description" content="摘要：数学在计算机科学、机器学习、深度学习、自然语言处理等多个领域占据比较重要的位置。比如：特征值和特征向量在PCA降维中会使用；均值在回归算法中估计公式参数中使用；期望和均值在回归方程应用；余弦定理求相似度中运用；拉格朗日定理在支持向量机中使用；求导在解决梯度下降中使用；矩阵和向量在数据格式转换和预处理中运用等等。还有在算法建模、参数设置、验证策略、识别欠拟合和过拟合等方面依然应用广泛。本系列">
<meta name="twitter:image" content="http://latex.codecogs.com/gif.latex?{\displaystyle {\begin{bmatrix}1&9&-13\\20&5&-6\end{bmatrix}}} ">



  <link rel="alternate" href="/atom.xml" title="白宁超的官网" type="application/atom+xml" />




  <link rel="canonical" href="https://bainingchao.github.io/2018/10/10/编程数学之矩阵/"/>



<script type="text/javascript" id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>编程数学之矩阵 | 白宁超的官网</title>
  









  <noscript>
  <style type="text/css">
    .use-motion .motion-element,
    .use-motion .brand,
    .use-motion .menu-item,
    .sidebar-inner,
    .use-motion .post-block,
    .use-motion .pagination,
    .use-motion .comments,
    .use-motion .post-header,
    .use-motion .post-body,
    .use-motion .collection-title { opacity: initial; }

    .use-motion .logo,
    .use-motion .site-title,
    .use-motion .site-subtitle {
      opacity: initial;
      top: initial;
    }

    .use-motion {
      .logo-line-before i { left: initial; }
      .logo-line-after i { right: initial; }
    }
  </style>
</noscript><!-- hexo-inject:begin --><!-- hexo-inject:end -->

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  
  
    
  

  <!-- hexo-inject:begin --><!-- hexo-inject:end --><div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

	<!-- <a href="https://github.com/bainingchao"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a> !-->
	
    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">白宁超的官网</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
      
        <h1 class="site-subtitle" itemprop="description">专注人工智能领域研究</h1>
      
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-首页">
    <a href="/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-home"></i> <br />首页</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-标签">
    <a href="/tags/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />标签</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-分类">
    <a href="/categories/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-th"></i> <br />分类</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-归档">
    <a href="/archives/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />归档</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-视频">
    <a href="/videos/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-sitemap"></i> <br />视频</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-书籍">
    <a href="/books/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-th"></i> <br />书籍</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-链接">
    <a href="/links/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-question-circle"></i> <br />链接</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-关于">
    <a href="/about/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-user"></i> <br />关于</a>
  </li>

      
      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />搜索</a>
        </li>
      
    </ul>
  

  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
            

          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://bainingchao.github.io/2018/10/10/编程数学之矩阵/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="白宁超">
      <meta itemprop="description" content="本站主要研究深度学习、机器学习、自然语言处理等前沿技术。ML&NLP交流群：436303759 <span><a target="_blank" href="http://shang.qq.com/wpa/qunwpa?idkey=ef3bbb679b06ac59b136c57ba9e7935ff9d3b10faeabde6e4efcafe523bbbf4d"><img border="0" src="http://pub.idqqimg.com/wpa/images/group.png" alt="自然语言处理和机器学习技术QQ交流：436303759 " title="自然语言处理和机器学习技术交流"></a></span>">
      <meta itemprop="image" content="/../images/header.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="白宁超的官网">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">编程数学之矩阵
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2018-10-10 16:25:52" itemprop="dateCreated datePublished" datetime="2018-10-10T16:25:52+08:00">2018-10-10</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2018-10-19 15:41:49" itemprop="dateModified" datetime="2018-10-19T15:41:49+08:00">2018-10-19</time>
              
            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/数学/" itemprop="url" rel="index"><span itemprop="name">数学</span></a></span>

                
                
                  ，
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/数学/矩阵/" itemprop="url" rel="index"><span itemprop="name">矩阵</span></a></span>

                
                
              
            </span>
          

          
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="post-meta-item-icon"
            >
            <i class="fa fa-eye"></i>
             阅读次数： 
            <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
            </span>
          
		  

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <blockquote>
<p>摘要：数学在计算机科学、机器学习、深度学习、自然语言处理等多个领域占据比较重要的位置。比如：特征值和特征向量在PCA降维中会使用；均值在回归算法中估计公式参数中使用；期望和均值在回归方程应用；余弦定理求相似度中运用；拉格朗日定理在支持向量机中使用；求导在解决梯度下降中使用；矩阵和向量在数据格式转换和预处理中运用等等。还有在算法建模、参数设置、验证策略、识别欠拟合和过拟合等方面依然应用广泛。本系列数学文章旨在带领大家快速回顾常用知识，重在理解。（本文原创，转载必须注明出处.）</p>
</blockquote>
<a id="more"></a>
<hr>
<h1 id="矩阵定义"><a href="#矩阵定义" class="headerlink" title="矩阵定义"></a>矩阵定义</h1><h2 id="矩阵定义-1"><a href="#矩阵定义-1" class="headerlink" title="矩阵定义"></a>矩阵定义</h2><p>数学上，一个m×n的矩阵是一个由m行n列元素排列成的矩形阵列。矩阵里的元素可以是数字、符号或数学式。以下是一个由6个数字元素构成的2行3列的矩阵：</p>
<p><img src="http://latex.codecogs.com/gif.latex?{\displaystyle {\begin{bmatrix}1&9&-13\\20&5&-6\end{bmatrix}}} "></p>
<p>大小相同（行数列数都相同）的矩阵之间可以相互加减，具体是对每个位置上的元素做加减法。矩阵的乘法则较为复杂。两个矩阵可以相乘，当且仅当第一个矩阵的列数等于第二个矩阵的行数。矩阵的乘法满足结合律和分配律，但不满足交换律。</p>
<h2 id="矩阵的理解"><a href="#矩阵的理解" class="headerlink" title="矩阵的理解"></a>矩阵的理解</h2><p>将一些元素排列成若干行，每行放上相同数量的元素，就是一个矩阵。这里说的元素可以是数字，例如以下的矩阵：</p>
<p><img src="http://latex.codecogs.com/gif.latex?{\displaystyle \mathbf {A} ={\begin{bmatrix}9&13&5\\1&11&7\\3&9&2\\6&0&7\end{bmatrix}}}  "></p>
<p>排列成的形状是矩形，所以称为矩阵。矩阵一般用大写拉丁字母表示，一般用方括号或圆括号括起。以上的矩阵<strong>A</strong>是一个4行3列的矩阵。</p>
<p>行数是1或列数是1的矩阵又可分别称为行向量和列向量。矩阵的任一行（列）都是一个行（列）向量，例如矩阵<strong>A</strong>的第一行\({\begin{bmatrix}9&amp;13&amp;5\end{bmatrix}}\)就是一个行向量。行（列）向量可以看成一个向量，因此可以称矩阵的两行（列）相等，或者某一行等于某一列，表示其对应的向量相等。</p>
<h2 id="增广矩阵"><a href="#增广矩阵" class="headerlink" title="增广矩阵"></a>增广矩阵</h2><p>矩阵的一个重要用途是解线性方程组。线性方程组中未知量的系数可以排成一个矩阵，加上常数项，则称为增广矩阵。</p>
<h2 id="矩阵表示"><a href="#矩阵表示" class="headerlink" title="矩阵表示"></a>矩阵表示</h2><p>一个矩阵<strong>A</strong>从左上角数起的第i行第j列上的元素称为第i,j项，通常记为<strong>A</strong>i,j、<strong>A</strong>ij、ai,j或<strong>A</strong>[i,j]，在上述例子中A[4,3] = 7。</p>
<hr>
<h1 id="矩阵运算"><a href="#矩阵运算" class="headerlink" title="矩阵运算"></a>矩阵运算</h1><h2 id="矩阵加法"><a href="#矩阵加法" class="headerlink" title="矩阵加法"></a>矩阵加法</h2><p>定义：m×n矩阵A和B的和，A+B为一个m×n矩阵，其中每个元素是A和B相应元素的和，\((A+B)_{ij}=A_{i,j}+B_{i,j}\),其中1 ≤ i ≤ m , 1 ≤ j ≤ n.</p>
<p>例子：</p>
<p><img src="http://latex.codecogs.com/gif.latex?\begin{bmatrix}
1 &3  &1 \\ 
1 &0  &0 
\end{bmatrix}+\begin{bmatrix}
0 &0  &5 \\ 
7 &5  &0 
\end{bmatrix}=\begin{bmatrix}
1+0 &3+0  &1+5 \\ 
1+7 &0+5  &0 +0
\end{bmatrix}=\begin{bmatrix}
1 &3  &6 \\ 
8 &5  &0 
\end{bmatrix}"></p>
<p>运算律(A，B，C都是同型矩阵)：</p>
<p>\( A+B=B+A \)</p>
<p>\((A+B)+C=A+(B+C)\)</p>
<p>应该注意的是只有同型矩阵之间才可以进行加法</p>
<h2 id="矩阵减法"><a href="#矩阵减法" class="headerlink" title="矩阵减法"></a>矩阵减法</h2><p>定义：m×n矩阵A和B的差，A-B为一个m×n矩阵，其中每个元素是A和B相应元素的差，\( (A-B)_{ij}=A_{i,j}-B_{i,j}\),其中1 ≤ i ≤ m , 1 ≤ j ≤ n.</p>
<p>例子：</p>
<p><img src="http://latex.codecogs.com/gif.latex?\begin{bmatrix}
1 &3  &1 \\ 
1 &0  &0 
\end{bmatrix}-\begin{bmatrix}
0 &0  &5 \\ 
7 &5  &0 
\end{bmatrix}=\begin{bmatrix}
1-0 &3-0  &1-5 \\ 
1-7 &0-5  &0 -0
\end{bmatrix}=\begin{bmatrix}
1 &3  &-4 \\ 
-6 &-5  &0 
\end{bmatrix}"></p>
<h2 id="矩阵数乘"><a href="#矩阵数乘" class="headerlink" title="矩阵数乘"></a>矩阵数乘</h2><p>定义：标量c与矩阵A的数乘：cA的每个元素是A的相应元素与c的乘积，\((cA)_{ij}=cA_{i,j}\)</p>
<p>例子：</p>
<p><img src="http://latex.codecogs.com/gif.latex?2*\begin{bmatrix}
1 &3  &1 \\ 
1 &0  &0 
\end{bmatrix}=\begin{bmatrix}
2*1 &2*3  &2*1 \\ 
2*1 &2*0  &2*0 
\end{bmatrix}=\begin{bmatrix}
2 &6  &2 \\ 
2 &0  &0 
\end{bmatrix}"></p>
<p>运算律：</p>
<ul>
<li><p>\((\lambda\mu )A=\lambda(\mu A)\)</p>
</li>
<li><p>\((\lambda+\mu )A=\lambda A+\mu A\)</p>
</li>
<li><p>\(\lambda(A+B)=\lambda A+\lambda B\)</p>
</li>
</ul>
<h2 id="矩阵转置"><a href="#矩阵转置" class="headerlink" title="矩阵转置"></a>矩阵转置</h2><p>定义：m×n矩阵A的转置是一个n×m的矩阵，记为\(A^T\)（其中的第i个行向量是原矩阵A的第i个列向量；或者说，转置矩阵\(A^T\)第i行第j列的元素是原矩阵A第j行第i列的元素，\((A^T)_{i,j}=A_{j,i}\)</p>
<p>例子：</p>
<p><img src="http://latex.codecogs.com/gif.latex?\begin{bmatrix}
1 &2  &3 \\ 
4 &5  &6 
\end{bmatrix}^T=\begin{bmatrix}
1 &4 \\ 
2 &5 \\ 
3 &6 
\end{bmatrix}"></p>
<p>运算律：</p>
<ul>
<li><p>\((A^T)^T=A\)</p>
</li>
<li><p>\((\lambda A)^T=\lambda A^T\)</p>
</li>
<li><p>\((A+B)^T=B^T+ A^T\)</p>
</li>
</ul>
<h2 id="共轭矩阵"><a href="#共轭矩阵" class="headerlink" title="共轭矩阵"></a>共轭矩阵</h2><p>定义：矩阵的共轭定义为:\( A_{i,j}= \overline A_{ij} \)。</p>
<p>例子：</p>
<p>一个2×2复数矩阵的共轭如下：<br><img src="http://latex.codecogs.com/gif.latex?A=\begin{bmatrix}
3+i &5  \\ 
2-2i  &i 
\end{bmatrix}"></p>
<p>则A的共轭矩阵是：</p>
<p><img src="http://latex.codecogs.com/gif.latex?\overline A=\begin{bmatrix}
3-i &5  \\ 
2+2i  &-i 
\end{bmatrix}"></p>
<h2 id="线性方程组"><a href="#线性方程组" class="headerlink" title="线性方程组"></a>线性方程组</h2><p>矩阵乘法的一个基本应用是在线性方程组上。线性方程组是方程组的一种，它符合以下的形式：<br><img src="http://latex.codecogs.com/gif.latex?{\displaystyle {\begin{cases}a_{1,1}x_{1}+a_{1,2}x_{2}+\cdots +a_{1,n}x_{n}=b_{1}\\a_{2,1}x_{1}+a_{2,2}x_{2}+\cdots +a_{2,n}x_{n}=b_{2}\\\vdots \quad \quad \quad \vdots \\a_{m,1}x_{1}+a_{m,2}x_{2}+\cdots +a_{m,n}x_{n}=b_{m}\end{cases}}} "></p>
<p>其中的\( a<em>{1,1},a</em>{1,2} \)  以及\( b<em>{1,1},b</em>{1,2}\)等等是已知的常数，而\( x_1,x_2\)等等则是要求的未知数。运用矩阵的方式，可以将线性方程组写成一个向量方程：\( \mathbf {A} \mathbf {x} =\mathbf {b} \)</p>
<p>其中，A是由方程组里未知量的系数排成的m×n 矩阵，x是含有n 个元素的行向量，b 是含有m 个元素的行向量。<br><img src="http://latex.codecogs.com/gif.latex?{\displaystyle \mathbf {A} ={\begin{bmatrix}a_{1,1}&a_{1,2}&\cdots &a_{1,n}\\a_{2,1}&a_{2,2}&\cdots &a_{2,n}\\\vdots &\vdots &\ddots &\vdots \\a_{m,1}&a_{m,2}&\cdots &a_{m,n}\end{bmatrix}},\quad \mathbf {x} ={\begin{bmatrix}x_{1}\\x_{2}\\\vdots \\x_{n}\end{bmatrix}},\quad \mathbf {b} ={\begin{bmatrix}b_{1}\\b_{2}\\\vdots \\b_{m}\end{bmatrix}}} "></p>
<p>这个写法下，将原来的多个方程转化成一个向量方程，在已知矩阵A和向量b的情况下，求未知向量x。</p>
<hr>
<h1 id="行列式"><a href="#行列式" class="headerlink" title="行列式"></a>行列式</h1><h2 id="方块矩阵"><a href="#方块矩阵" class="headerlink" title="方块矩阵"></a>方块矩阵</h2><p>方块矩阵是行数与列数相同的矩阵称为方块矩阵，简称方阵。如下表示：</p>
<p><img src="http://latex.codecogs.com/gif.latex?A=\begin{bmatrix}
a_{1,1}  &a_{1,2}  \\ 
a_{2,1}  &a_{2,2} 
\end{bmatrix}"></p>
<h2 id="逆矩阵"><a href="#逆矩阵" class="headerlink" title="逆矩阵"></a>逆矩阵</h2><p>方阵A称为可逆或非奇异的，如果存在另一个方阵B，使得\(AB=I_n\)成立。这时候可以证明也有\(BA=I_n\)成立，可将矩阵B称为A的逆矩阵。一个矩阵A的逆矩阵如果存在的话，就是唯一的，通常记作\(A^{-1}\)。</p>
<h2 id="矩阵的迹"><a href="#矩阵的迹" class="headerlink" title="矩阵的迹"></a>矩阵的迹</h2><p>矩阵A的元素Ai,i称为其主对角线上的元素。方块矩阵A的所有主对角线元素之和称为它的迹，写作tr(A)。</p>
<p>例子：</p>
<p><img src="http://latex.codecogs.com/gif.latex?A=\begin{bmatrix}
a_{1,1}  &a_{1,2}  \\ 
a_{2,1}  &a_{2,2} 
\end{bmatrix}"></p>
<p>A的迹是\(tr(A)=a_{1,1}a_{2,2}\)</p>
<p>矩阵的迹具备以下特征：</p>
<p>尽管矩阵的乘法不满足交换律，方阵相乘时交换顺序会导致乘积变化，但它们的迹不会变，即：\(tr(AB)=tr(BA)\).矩阵转置的迹等于其自身的迹，\(tr(A)=tr(A^T)\)</p>
<h2 id="对角矩阵"><a href="#对角矩阵" class="headerlink" title="对角矩阵"></a>对角矩阵</h2><p>如果一个方阵只有主对角线上的元素不是0，其它都是0，那么称其为对角矩阵。如下所示：<br><img src="http://latex.codecogs.com/gif.latex?\begin{bmatrix}
           d_{11} & 0 & 0 \\
           0 & d_{22} & 0 \\
           0 & 0 & d_{33} \\
        \end{bmatrix}"></p>
<h2 id="上三角矩阵"><a href="#上三角矩阵" class="headerlink" title="上三角矩阵"></a>上三角矩阵</h2><p>如果主对角线下方的元素都是0，那么称为上三角矩阵。如下所示：</p>
<p><img src="http://latex.codecogs.com/gif.latex?\begin{bmatrix}
           u_{11} & u_{12} & u_{13} \\
           0 & u_{22} & u_{23} \\
           0 & 0 & u_{33} \\
        \end{bmatrix}"></p>
<h2 id="下三角矩阵"><a href="#下三角矩阵" class="headerlink" title="下三角矩阵"></a>下三角矩阵</h2><p>如果主对角线上方的元素都是0，那么称为下三角矩阵，如下所示：</p>
<p><img src="http://latex.codecogs.com/gif.latex?\begin{bmatrix}
           l_{11} & 0 & 0 \\
           l_{21} & l_{22} & 0 \\
           l_{31} & l_{32} & l_{33} \\
        \end{bmatrix}"></p>
<h2 id="行列式-1"><a href="#行列式-1" class="headerlink" title="行列式"></a>行列式</h2><blockquote>
<p>1×1方阵的行列式为该元素本身。</p>
</blockquote>
<p></p><p><img src="http://latex.codecogs.com/gif.latex?A=(a_{11})">
</p><br><img src="http://latex.codecogs.com/gif.latex?|A|=a_{11}"><p></p>
<blockquote>
<p>2×2方阵，其行列式用主对角线元素乘积减去次对角线元素的乘积。 </p>
</blockquote>
<p></p><p><img src="http://latex.codecogs.com/gif.latex?A=\begin{pmatrix}
a_{11} & a_{12} \\
a_{21} & a_{22} 
\end{pmatrix}">
</p><br><img src="http://latex.codecogs.com/gif.latex?|A|=a_{11}a_{22}-a_{12}a_{21}"><p></p>
<blockquote>
<p>3×3阶方阵 </p>
</blockquote>
<p></p><p><img src="http://latex.codecogs.com/gif.latex?A=\begin{pmatrix}
a_{11} & a_{12} & a_{13} \\
a_{21} & a_{22} & a_{23} \\
a_{31} & a_{32} & a_{33}
\end{pmatrix}">
</p><br>三阶矩阵发现\(a<em>{12}\)的对角线少一部分（也就是\(a</em>{23}\)的右下部分缺失）。一种方法是copy三个完全一样的矩阵做补充。<br><img src="https://i.imgur.com/a9DmDiZ.png" alt=""><br><img src="http://latex.codecogs.com/gif.latex?|A|=a_{11}a_{22}a_{33}+a_{12}a_{23}a_{31}+a_{13}a_{21}a_{32}-a_{11}a_{23}a_{32}-a_{12}a_{21}a_{33}-a_{13}a_{22}a_{31}"><p></p>
<p>另一种方式就是利用代数余子式来计算:</p>
<p>在一个n阶行列式A中，把(i,j)元素\(a_{ij}\)所在的第i行和第j列划去后，留下的n−1阶方阵的行列式叫做元素\(a_{ij}\)的余子式，记作\(M_{ij}\)。代数余子式：\( A_{ij}=(-1)^{i+j}M_{ij} \).注意：代数余子式是个数值！</p>
<p>下图方框里计算的值便是\(a_{11}a_{12}\)的代数余子式\(M_{11}M_{12}\)</p>
<p><img src="https://i.imgur.com/5dhejWE.png" alt=""></p>
<p><img src="https://i.imgur.com/gJYS8oI.png" alt=""></p>
<p>n阶的行列式等于它的任意一行（或列）的各元素与其对应的代数余子式乘积之和。<br>对于任意一列：</p>
<p><img src="http://latex.codecogs.com/gif.latex?|A|=\sum_{i=1}^{n}a_{ij}(-1)^{i+j}M_{ij} , \forall \leqslant j \leqslant n"> </p>
<p>对于任意一行：</p>
<p><img src="http://latex.codecogs.com/gif.latex?|A|=\sum_{j=1}^{n}a_{ij}(-1)^{i+j}M_{ij} , \forall \leqslant i \leqslant n"></p>
<p>所以上面三阶方阵的行列式A就是：</p>
<p><img src="http://latex.codecogs.com/gif.latex?|A|=a_{11}(a_{22}a_{33}-a_{23}a_{32})+a_{12}(a_{21}a_{33}-a_{23}a_{31})+a_{13}(a_{21}a_{32}-a_{23}a_{31})"></p>
<hr>
<h1 id="特征值和特征向量"><a href="#特征值和特征向量" class="headerlink" title="特征值和特征向量"></a>特征值和特征向量</h1><p>n×n的方块矩阵A的一个特征值和对应特征向量是满足\(\mathbf {Av} =\lambda \mathbf {v} \)的标量\(\lambda \)以及非零向量\(\mathbf {v}\)。特征值和特征向量的概念对研究线性变换很有帮助。一个线性变换可以通过它对应的矩阵在向量上的作用来可视化。一般来说，一个向量在经过映射之后可以变为任何可能的向量，而特征向量具有更好的性质。假设在给定的基底下，一个线性变换对应着某个矩阵A，如果一个向量x可以写成矩阵的几个特征向量的线性组合：\( \mathbf{x} = c_1 \mathbf{x}_{\lambda_1}+c_2\mathbf {x}_{\lambda_2}+\cdots +c_k\mathbf{x}_{\lambda_k} \)</p>
<p>其中的\( \mathbf{x}_{\lambda_i}\)  表示此向量对应的特征值是\(\lambda_i\)，那么向量x经过线性变换后会变成：\({\displaystyle \mathbf {Ax} =c_{1}\lambda_{1}\mathbf {x}_{\lambda_{1}}+c_{2}\lambda_{2}\mathbf {x}_{\lambda_{2}}+\cdots +c_{k}\lambda_{k}\mathbf {x}_{\lambda_{k}}}  \).可以清楚地知道变换后向量的结构。另一个等价的特征值定义是：标量\(\lambda\)为特征值，如果矩阵\( \mathbf{A} -\lambda {\mathsf {I}}_n \) 是不可逆矩阵。根据不可逆矩阵的性质，这个定义也可以用行列式方程描述：\(\lambda\)为特征值，如果\(\det(\lambda {\mathsf {I}}_n-\mathbf {A} )=0.\)<br> 这个定义中的行列式可以展开成一个关于\(\lambda\)的n阶多项式，叫做矩阵A的特征多项式，记为\(p_A\)。特征多项式是一个首一多项式（最高次项系数是1的多项式）。它的根就是矩阵A特征值。哈密尔顿－凯莱定理说明，如果用矩阵A本身代替多项式中的不定元 \( \lambda\) ，那么多项式的值是零矩阵：\( p_{\mathbf {A} }(\mathbf {A} )=0 \)</p>
<hr>
<h1 id="参考文献"><a href="#参考文献" class="headerlink" title="参考文献"></a>参考文献</h1><ol>
<li><a href="https://www.python.org/downloads/" target="_blank" rel="noopener">Python官网</a></li>
<li><a href="https://zh.wikipedia.org/wiki/Python" target="_blank" rel="noopener">中文维基百科</a></li>
<li><a href="https://github.com/BaiNingchao/MachineLearning-1" target="_blank" rel="noopener">GitHub</a></li>
<li>图书：《机器学习实战》</li>
<li><a href="https://baike.baidu.com/item/%E8%87%AA%E7%84%B6%E8%AF%AD%E8%A8%80%E5%A4%84%E7%90%86%E7%90%86%E8%AE%BA%E4%B8%8E%E5%AE%9E%E6%88%98" target="_blank" rel="noopener">图书：《自然语言处理理论与实战》</a></li>
</ol>
<h1 id="完整代码下载"><a href="#完整代码下载" class="headerlink" title="完整代码下载"></a>完整代码下载</h1><blockquote>
<p>源码请进【机器学习和自然语言QQ群：436303759】文件下载：<a target="_blank" href="http://shang.qq.com/wpa/qunwpa?idkey=ef3bbb679b06ac59b136c57ba9e7935ff9d3b10faeabde6e4efcafe523bbbf4d"><img border="0" src="http://pub.idqqimg.com/wpa/images/group.png" alt="自然语言处理和机器学习技术QQ交流" title="自然语言处理和机器学习技术交流"></a></p>
</blockquote>
<p><img src="https://i.imgur.com/cvixeiT.png" alt=""></p>
<h1 id="作者声明"><a href="#作者声明" class="headerlink" title="作者声明"></a>作者声明</h1><blockquote>
<p>本文版权归作者所有，旨在技术交流使用。未经作者同意禁止转载，转载后需在文章页面明显位置给出原文连接，否则相关责任自行承担。</p>
</blockquote>

      
    </div>

    

    
    
    

    
      <div>
        <div id="wechat_subscriber" style="display: block; padding: 10px 0; margin: 20px auto; width: 100%; text-align: center">
    <img id="wechat_subscriber_qcode" src="/uploads/wechat.png" alt="白宁超 wechat" style="width: 200px; max-width: 100%;"/>
    <div>扫一扫关注微信公众号，机器学习和自然语言处理，订阅号datathinks！</div>
</div>

      </div>
    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div></div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/images/wechatpay.jpg" alt="白宁超 微信支付"/>
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/images/alipay.jpg" alt="白宁超 支付宝"/>
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/数学/" rel="tag"><i class="fa fa-tag"></i> 数学</a>
          
            <a href="/tags/矩阵/" rel="tag"><i class="fa fa-tag"></i> 矩阵</a>
          
        </div>
      

      
      
        <div class="post-widgets">
        

        

        
          
          <div class="social_share">
            
               <div>
                 
  <div class="bdsharebuttonbox">
    <a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
    <a href="#" class="bds_douban" data-cmd="douban" title="分享到豆瓣网"></a>
    <a href="#" class="bds_sqq" data-cmd="sqq" title="分享到QQ好友"></a>
    <a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
    <a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
    <a href="#" class="bds_tieba" data-cmd="tieba" title="分享到百度贴吧"></a>
    <a href="#" class="bds_twi" data-cmd="twi" title="分享到Twitter"></a>
    <a href="#" class="bds_fbook" data-cmd="fbook" title="分享到Facebook"></a>
    <a href="#" class="bds_more" data-cmd="more"></a>
    <a class="bds_count" data-cmd="count"></a>
  </div>
  <script>
    window._bd_share_config = {
      "common": {
        "bdText": "",
        "bdMini": "2",
        "bdMiniList": false,
        "bdPic": ""
      },
      "share": {
        "bdSize": "16",
        "bdStyle": "0"
      },
      "image": {
        "viewList": ["tsina", "douban", "sqq", "qzone", "weixin", "twi", "fbook"],
        "viewText": "分享到：",
        "viewSize": "16"
      }
    }
  </script>

<script>
  with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='/static/api/js/share.js?cdnversion='+~(-new Date()/36e5)];
</script>

               </div>
            
            
               <div id="needsharebutton-postbottom">
                 <span class="btn">
                    <i class="fa fa-share-alt" aria-hidden="true"></i>
                 </span>
               </div>
            
          </div>
        
        </div>
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/10/10/编程数学之向量/" rel="next" title="编程数学之向量">
                <i class="fa fa-chevron-left"></i> 编程数学之向量
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/10/10/编程数学之距离计算/" rel="prev" title="编程数学之距离计算">
                编程数学之距离计算 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>


  </div>


          </div>
          

  
    <div class="comments" id="comments">
      <div id="lv-container" data-id="city" data-uid="MTAyMC8zOTc5NC8xNjMyMQ=="></div>
    </div>

  
 





        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/../images/header.png"
                alt="白宁超" />
            
              <p class="site-author-name" itemprop="name">白宁超</p>
              <p class="site-description motion-element" itemprop="description">本站主要研究深度学习、机器学习、自然语言处理等前沿技术。ML&NLP交流群：436303759 <span><a target="_blank" href="http://shang.qq.com/wpa/qunwpa?idkey=ef3bbb679b06ac59b136c57ba9e7935ff9d3b10faeabde6e4efcafe523bbbf4d"><img border="0" src="http://pub.idqqimg.com/wpa/images/group.png" alt="自然语言处理和机器学习技术QQ交流：436303759 " title="自然语言处理和机器学习技术交流"></a></span></p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives">
                
                    <span class="site-state-item-count">65</span>
                    <span class="site-state-item-name">日志</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  <a href="/categories/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">29</span>
                    <span class="site-state-item-name">分类</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  <a href="/tags/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">119</span>
                    <span class="site-state-item-name">标签</span>
                  </a>
                </div>
              
            </nav>
          

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          
            <div class="links-of-author motion-element">
              
                <span class="links-of-author-item">
                  <a href="https://github.com/bainingchao" target="_blank" title="GitHub" rel="external nofollow"><i class="fa fa-fw fa-github"></i>GitHub</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="https://www.google.com.hk/" target="_blank" title="Google" rel="external nofollow"><i class="fa fa-fw fa-google"></i>Google</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="https://www.baidu.com/" target="_blank" title="百度" rel="external nofollow"><i class="fa fa-fw fa-globe"></i>百度</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="https://weibo.com/p/1005056002073632?is_all=1" target="_blank" title="微博" rel="external nofollow"><i class="fa fa-fw fa-weibo"></i>微博</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="http://www.cnblogs.com/baiboy/" target="_blank" title="博客园" rel="external nofollow"><i class="fa fa-fw fa-globe"></i>博客园</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="https://mp.weixin.qq.com/s/s97I4gtEJIt5rMivWMkPkQ" target="_blank" title="微信公众号" rel="external nofollow"><i class="fa fa-fw fa-weixin"></i>微信公众号</a>
                  
                </span>
              
            </div>
          

          
          

          
          

          
            
          
          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#矩阵定义"><span class="nav-number">1.</span> <span class="nav-text">矩阵定义</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#矩阵定义-1"><span class="nav-number">1.1.</span> <span class="nav-text">矩阵定义</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#矩阵的理解"><span class="nav-number">1.2.</span> <span class="nav-text">矩阵的理解</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#增广矩阵"><span class="nav-number">1.3.</span> <span class="nav-text">增广矩阵</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#矩阵表示"><span class="nav-number">1.4.</span> <span class="nav-text">矩阵表示</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#矩阵运算"><span class="nav-number">2.</span> <span class="nav-text">矩阵运算</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#矩阵加法"><span class="nav-number">2.1.</span> <span class="nav-text">矩阵加法</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#矩阵减法"><span class="nav-number">2.2.</span> <span class="nav-text">矩阵减法</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#矩阵数乘"><span class="nav-number">2.3.</span> <span class="nav-text">矩阵数乘</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#矩阵转置"><span class="nav-number">2.4.</span> <span class="nav-text">矩阵转置</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#共轭矩阵"><span class="nav-number">2.5.</span> <span class="nav-text">共轭矩阵</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#线性方程组"><span class="nav-number">2.6.</span> <span class="nav-text">线性方程组</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#行列式"><span class="nav-number">3.</span> <span class="nav-text">行列式</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#方块矩阵"><span class="nav-number">3.1.</span> <span class="nav-text">方块矩阵</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#逆矩阵"><span class="nav-number">3.2.</span> <span class="nav-text">逆矩阵</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#矩阵的迹"><span class="nav-number">3.3.</span> <span class="nav-text">矩阵的迹</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#对角矩阵"><span class="nav-number">3.4.</span> <span class="nav-text">对角矩阵</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#上三角矩阵"><span class="nav-number">3.5.</span> <span class="nav-text">上三角矩阵</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#下三角矩阵"><span class="nav-number">3.6.</span> <span class="nav-text">下三角矩阵</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#行列式-1"><span class="nav-number">3.7.</span> <span class="nav-text">行列式</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#特征值和特征向量"><span class="nav-number">4.</span> <span class="nav-text">特征值和特征向量</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#参考文献"><span class="nav-number">5.</span> <span class="nav-text">参考文献</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#完整代码下载"><span class="nav-number">6.</span> <span class="nav-text">完整代码下载</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#作者声明"><span class="nav-number">7.</span> <span class="nav-text">作者声明</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>

<div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">白宁超</span>

  

  
</div>




  



  <!--<div class="powered-by">由 <a class="theme-link" target="_blank" rel="external nofollow" href="https://hexo.io">Hexo</a> 强力驱动 v3.7.1</div> -->



   <!--<span class="post-meta-divider">|</span>-->



   <!--<div class="theme-info">主题 – <a class="theme-link" target="_blank" rel="external nofollow" href="https://theme-next.org">NexT.Gemini</a> v6.4.1</div>-->




        <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>



<div class="busuanzi-count">
  
    <span class="site-uv" title="总访客量">
      <i class="fa fa-user"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
    </span>
  

  
    <span class="site-pv" title="总访问量">
      <i class="fa fa-eye"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
    </span>
  
</div>









        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    
	
    

    
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>


























  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=6.4.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=6.4.1"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=6.4.1"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=6.4.1"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=6.4.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=6.4.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=6.4.1"></script>



  



  
    <script type="text/javascript">
      window.livereOptions = {
        refer: '2018/10/10/编程数学之矩阵/'
      };
      (function(d, s) {
        var j, e = d.getElementsByTagName(s)[0];
        if (typeof LivereTower === 'function') { return; }
        j = d.createElement(s);
        j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
        j.async = true;
        e.parentNode.insertBefore(j, e);
      })(document, 'script');
    </script>
  










  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  
  

  
  

  
    
      <script type="text/x-mathjax-config">
    MathJax.Hub.Config({
      tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
        processEscapes: true,
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      },
      TeX: {equationNumbers: { autoNumber: "AMS" }}
    });
</script>

<script type="text/x-mathjax-config">
    MathJax.Hub.Queue(function() {
      var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
    });
</script>
<script type="text/javascript" src="//cdn.jsdelivr.net/npm/mathjax@2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

    
  


  
  
  
  <script src="/lib/needsharebutton/needsharebutton.js"></script>

  <script>
    
      pbOptions = {};
      
          pbOptions.iconStyle = "box";
      
          pbOptions.boxForm = "horizontal";
      
          pbOptions.position = "bottomCenter";
      
          pbOptions.networks = "Weibo,Wechat,Douban,QQZone,Linkedin,Facebook";
      
      new needShareButton('#needsharebutton-postbottom', pbOptions);
    
    
  </script>

  

  

  

  

  

  

  <!-- 页面点击小红心 -->
	<script type="text/javascript" src="../js/src/love.js"></script><!-- hexo-inject:begin --><!-- Begin: Injected MathJax -->
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({"tex2jax":{"inlineMath":[["$","$"],["\\(","\\)"]],"skipTags":["script","noscript","style","textarea","pre","code"],"processEscapes":true},"TeX":{"equationNumbers":{"autoNumber":"AMS"}}});
</script>

<script type="text/x-mathjax-config">
  MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
      all[i].SourceElement().parentNode.className += ' has-jax';
    }
  });
</script>

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js">
</script>
<!-- End: Injected MathJax -->
<!-- hexo-inject:end -->
</body>
</html>
